﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BotvaBot.RequestChains.Base;
using BotvaBot.RequestChainItems;
using BotvaBot.BusinessLayer.Enums;

namespace BotvaBot.RequestChains
{
    public class ActivateKulonChain : BotvaChainBase
    {
        public Kulon KulonType { get; set; }
        
        public ActivateKulonChain()
            : base()
        { }

        public ActivateKulonChain(BotvaChainContext parentContext)
            : base(parentContext)
        { }


        public int GildiaId { get; set; }
        public int LetunId { get; set; }

        public override void Init()
        {
            base.Init();

            AddItem(new EnterChainItem(), () => !WithInheritedContext);
            AddItem(new LoginChainItem(), () => !WithInheritedContext);
            AddItem(new ActivateKulonChainItem());
            AddItem(new LogoutChainItem(), () => !WithInheritedContext);
        }

        protected override void PrepareRunChain()
        {
            base.PrepareRunChain();

            ActivateKulonChainItem activateKulonChainItem = Chain.Values
                .Where(chi => chi.GetType() == typeof(ActivateKulonChainItem)).First() as ActivateKulonChainItem;
            activateKulonChainItem.KulonType = KulonType;
        }

    }
}
